package mtons.cast.modules.data;

/**
 * Created by langhsu on 2017/10/13.
 */
public class Result<T> {
    public static int STATUC_OK = 200;
    public static int STATUC_ERROR = 500;

    private int code;
    private String message;
    private T data;

    public static Result success() {
        return success(null);
    }

    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(200);
        result.setMessage("success");
        result.setData(data);
        return result;
    }

    public static Result error() {
        return error(null);
    }

    public static Result error(String message) {
        return error(Result.STATUC_ERROR, message);
    }

    public static Result error(int code, String message) {
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        result.setData(null);
        return result;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
